-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scaling factor option #28253
Add scaling factor option #28253
Conversation
@Night-Pryanik This shouldn't be labeled as |
c2148f2
to
e7847ef
Compare
Noticed that a few pixels could end up missing at some terminal sizes as a result of this, so completely disabled it by default. Still need someone to test this on a 4K display... |
What exactly should this be doing? Why would you need a 4k display to test this? It should scale up the text on any resolution?! |
You're right, upon further investigation this isn't doing exactly what I thought it was. Still not sure exactly why though as the documentation led me to believe that this was the proper fix. I think I've got something else working though, will do some testing and hopefully push a real solution soon. |
900d806
to
a684100
Compare
src/sdltiles.cpp
Outdated
@@ -2963,8 +2978,22 @@ void catacurses::init_interface() | |||
|
|||
find_videodisplays(); | |||
|
|||
TERMINAL_WIDTH = get_option<int>( "TERMINAL_X" ); | |||
TERMINAL_HEIGHT = get_option<int>( "TERMINAL_Y" ); | |||
std::string scaling_factor_setting = get_option<std::string>( "SCALING_FACTOR" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you get option value as an int
and set scaling_factor
based directly on that value, something like
scaling_factor = get_option<int>( "SCALING_FACTOR" );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too, but that causes an abnormal termination for some reason.
Got it to work with 2x ... kinda The options needs a mention to restart the game though or you have to reload the ui after chaging it. Got a crash at 4x on 4k at first but can also happen on 2x. Windows and Linux same error:
|
Yeah you're exactly right about what's causing the crash, 4x should work if you set your terminal size is 4 times the minimum 80x24 or higher, 2x if it 2x times or higher. I'm probably gonna have to approach this a little differently, and have setting the scaling factor actually force the terminal size option to change, bringing it within the valid range if necessary. Don't think any other options are linked like that however, so not sure about the best way to do that. |
Alright, I can't seem to get it to crash any more, so we're making progress. It sometimes does weird things on resizing if you change the scaling factor and don't restart. Looks like this should be pretty much ready after some more testing and cleanup. Edit: also took out the 8x because I can't see anyone ever using that, but I can put it back of course if someone thinks it would get used. |
98f0f21
to
3c25871
Compare
Ok I think this is ready for merging, I've been trying for a while to get it to crash without success, and the resizing really isn't much funkier that what we currently have on master. It only does weird things when using the options menu to adjust the size, resizing the window by dragging the corner works fine. Fullscreen seems to work fine too, and borderless window as well. I have a very basic knowledge of SDL, and have mostly been making this work through experimentation so there may be something I did totally wrong. However, as far as I can tell this works fine, and should make the game a bit more legible on those 4K displays. |
Can confirm. Works without crashes now on Win and Linux. |
Perfect, I'm on macOS so that's all 3 covered then. |
Crash on my system, though I'm willing to believe my settings were illegal? I took a "correctly" sized window and then just set scaling factor to 2x, should I have shrunk my size first?
|
Ehhhh.... I'm on a rather low resolution system (1366x768) and I can't seem to set a terminal width/height that allows for doubling. |
The way I implemented this may be a little misleading, the terminal size/height options won't change, but internally they will be treated as 1/2 or 1/4 of their set value (the user will see 160x48 for example at 2x minimum size). If that results in a dimension that is smaller than the minimum 80x24 the setting should be set to respect the minimum, which has worked fine for me so far. What happens on mine if I use 4x is that it creates a window that's larger than my display, but doesn't crash. I assume your system doesn't allow windows to be larger than the display, hence the crash. Just realized that it probably would crash on mine in fullscreen as well. I'll look in to disabling this for displays that are too small. My laptop is also 1366x768, so I should be able to test that without issue. Have only tested on my 1920x1080 monitor so far though. |
f78d798
to
23646c0
Compare
So, right now this is checking against display size, which is not always equivalent to maximum window size. For example, there is often a bar/dock/whatever that takes up some vertical or horizontal space. Unfortunately, SDL does not provide a cross platform way to check for maximum window size as far as I can tell. I'm not really sure what to do about that, because I have no idea where to start with digging up platform specific api stuff to get that information. However, except for with kevin's weird window manager, having windows that are larger than the screen size seems to be OK. The check against display size does 100% prevent crashing when using a borderless window. |
TERMX -= TERMX % scaling_factor; | ||
TERMY -= TERMY % scaling_factor; | ||
get_option( "TERMINAL_X" ).setValue( std::max( 80 * scaling_factor, TERMX ) ); | ||
get_option( "TERMINAL_Y" ).setValue( std::max( 24 * scaling_factor, TERMY ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace 80
and 24
magic numbers with FULL_SCREEN_WIDTH
and FULL_SCREEN_HEIGHT
respectively, here and below.
Merged to 0.D and master. |
Yeah, changing that to use |
Summary
SUMMARY: Interface "Add scaling factor option."
Purpose of change
Fixes #26579.
Describe the solution
Uses
SDL_RenderSetLogicalSize()
to effectively scale the window based on a new option,SCALING_FACTOR
.Also adjusts
TERMINAL_HEIGHT
andTERMINAL_WIDTH
accordinglyDescribe alternatives you've considered
It would be nice to autoset this option based on dpi, but I haven't looked into what that would involve.
Additional context
This will currently crash occasionally on startup if set to something other that 1x. Will need to do some investigation into why that is. If initialization is successful however, 2x seems to work very well. Every pixel in game is represented by 4 pixels on the display. I'm not sure if 4x, or 8x would ever be used, but it may be good to include them anyways.